<?php
	include "../../public/commom/config.php";
	include "../lock1.php";
?>

<!DOCTYPE html>
<html>
	
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="../public/css/index.css"/>
	</head>
	
	<body>
		<div id="main">
			<h1>订单表</h1>
			<table class="table table-bordered">
				<thead>
					<tr><th>编号</th><th>订单号</th><th>买家</th><th>商品</th><th>数量</th><th>共计</th><th>联系方式</th><th>下单时间</th><th>订单状态</th><th>操作</th><th>操作</th></tr>
				</thead>
				<tbody>
					<?php
						date_default_timezone_set("PRC");
						
						$sql = "SELECT indent.*, user.username uname, shop.name sname, touch.tel, status.name from indent LEFT JOIN user ON (indent.user_id = user.id) LEFT JOIN shop ON (indent.shop_id = shop.id) LEFT JOIN touch ON (indent.touch_id = touch.id) LEFT JOIN status ON (indent.status_id = status.id) GROUP BY indent.code";
					
						$result = mysqli_query($conn, $sql);
						
						while($row = mysqli_fetch_array($result)) {
							echo "<tr>
									<td>" . $row["id"] . "</td>
									<td><a href='code.php?code=" . $row["code"] . "'>" . $row["code"] . "</a></td>
									<td>" . $row["uname"] . "</td>
									<td>" . $row["sname"] . "</td>
									<td>" . $row["num"] . "</td>
									<td>" . $row["price"] . "</td>
									<td><a href='tel.php?tel=" . $row["tel"] . "'>" . $row["tel"] . "</a></td>
									<td>" . date("Y-m-d H:i:s", $row["time"]) . "</td>
									<td>" . $row["name"] . "</td>
									<td><a href='xiugai.php?id=" . $row["id"] . "&code=" . $row["code"] . "&status=" . $row["status_id"] . "'>修改</a></td>
									<td><a href='delete.php?code=" . $row["code"] . "'>删除</a></td>
								</tr>";
						}
						
						mysqli_close($conn);
					?>
				</tbody>
				
			</table>
		</div>
	</body>
	
</html>
<!--
	作者：730088787@qq.com
	时间：2018-11-12
	描述：GROUP BY//同个code的记录只查一条
-->